package com.fragment3;


import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.common.base.BaseFragment;
import com.common.event.EventBusUtil;
import com.common.event.MessageEvent;
import com.common.route.RouterPath;
import com.fragment3.databinding.MessageBinding;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

@Route(path = RouterPath.MESSAGE_FRAGMENT)
public class MessageFragment extends BaseFragment<MessageBinding> {

    @Override
    protected Class<MessageBinding> getBindingClass() {
        return MessageBinding.class;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        binding.tvTitle.setText("消息");
        EventBusUtil.register(this);
    }

    @Override
    protected void loadData() {
        // 加载消息数据
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(MessageEvent event) {
        binding.tvMessage.setText("收到消息: " + event.getMessage());
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBusUtil.unregister(this);
    }

    @Override
    public void onTabReselected() {
        // 刷新消息
        binding.tvMessage.setText("消息已刷新");
    }
}
